/*---------------------------------------------------------------------------*\
|* This file is part of the koala project with MIT License.                  *|
|* Copyright (c) James <zhuguangxiang@gmail.com>                             *|
\*--------------------------------------------------------------------------**/

#include "ir.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * (1) var is defined only once and not used and this definition is useless.
 * (2) var is defined more than once continuely and the last one is useful.
 */
void remove_useless_set_local(KlrValue *var)
{
    KlrInsn *insn;
    KlrUse *use;
    int last = 0;

    use_foreach(use, var->use_list)
    {
        insn = use->insn;
        if (insn->opcode == KLR_INSN_SET_LOCAL) {
            if (last == 1) klr_remove_insn(insn);
            last = 1;
        } else {
            last = 0;
        }
    }
}

void do_lsra(KlrFunc *func) {}

#ifdef __cplusplus
}
#endif
